home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / WizardModelAbstract.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  4.7 KB  |  144 lines

  1. package asp.wizard;
  2.  
  3. import asp.netobjects.nfx.util.ExceptionHandler;
  4. import asp.netobjects.nfx.util.ExternalError;
  5. import asp.netobjects.nfx.util.InternalError;
  6. import asp.netobjects.nfx.wizard.Wizard;
  7. import asp.netobjects.nfx.wizard.WizardPage;
  8. import asp.netobjects.nfx.wizard.WizardPageView;
  9. import asp.wizard.def.DefPage;
  10. import com.sun.java.swing.ImageIcon;
  11.  
  12. public class WizardModelAbstract extends WizardPage {
  13.    protected static final String IMG_DIR = "image";
  14.    private DefPage _defPage;
  15.    private int _templateId = -1;
  16.    private boolean _skip = false;
  17.  
  18.    public WizardModelAbstract() {
  19.       super((Wizard)null, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
  20.       super.dmIsLastPage = false;
  21.    }
  22.  
  23.    public WizardModelAbstract(Wizard wizard, String bullet, String info, ImageIcon icon, ExceptionHandler handler) {
  24.       super(wizard, bullet, info, icon, handler);
  25.       super.dmIsLastPage = false;
  26.    }
  27.  
  28.    protected WizardManager getWizardManager() {
  29.       return (WizardManager)((WizardPage)this).getWizard();
  30.    }
  31.  
  32.    public void createView() throws InternalError {
  33.       super.dmWizardPageView = this.getViewSingleInstance();
  34.       if (super.dmWizardPageView == null) {
  35.          throw new InternalError(this.getClass().getName() + ".createView(): " + "getViewSingleInstance() " + "returned null");
  36.       }
  37.    }
  38.  
  39.    protected WizardPageView getViewSingleInstance() {
  40.       return null;
  41.    }
  42.  
  43.    public DefPage getDefPage() {
  44.       return this._defPage;
  45.    }
  46.  
  47.    public void setDefPage(DefPage defPage) {
  48.       this._defPage = defPage;
  49.    }
  50.  
  51.    public int getTemplateId() {
  52.       return this._templateId;
  53.    }
  54.  
  55.    void setTemplateId(int templateid) {
  56.       this._templateId = templateid;
  57.    }
  58.  
  59.    public WizardPage getNext() throws InternalError, ExternalError {
  60.       WizardPage result = null;
  61.       if (this.getWizardManager() != null) {
  62.          WizardManager wizman = this.getWizardManager();
  63.          if (wizman.isModelSkippingEnabled()) {
  64.             WizardPage curr;
  65.             for(curr = wizman.getNextModel(this); curr != null && ((WizardModelAbstract)curr).isSkip(); curr = wizman.getNextModel(curr)) {
  66.             }
  67.  
  68.             result = curr;
  69.          } else {
  70.             result = wizman.getNextModel(this);
  71.          }
  72.       } else {
  73.          result = super.getNext();
  74.       }
  75.  
  76.       return result;
  77.    }
  78.  
  79.    public WizardPage getPrevious() throws InternalError, ExternalError {
  80.       WizardPage result = null;
  81.       if (this.getWizardManager() != null) {
  82.          WizardManager wizman = this.getWizardManager();
  83.          if (wizman.isModelSkippingEnabled()) {
  84.             WizardPage curr;
  85.             for(curr = wizman.getPreviousModel(this); curr != null && ((WizardModelAbstract)curr).isSkip(); curr = wizman.getPreviousModel(curr)) {
  86.             }
  87.  
  88.             result = curr;
  89.          } else {
  90.             result = wizman.getPreviousModel(this);
  91.          }
  92.       } else {
  93.          result = super.getPrevious();
  94.       }
  95.  
  96.       return result;
  97.    }
  98.  
  99.    public String getBulletText() {
  100.       return null;
  101.    }
  102.  
  103.    public String getInfoText() {
  104.       return null;
  105.    }
  106.  
  107.    public void initialize(int direction) throws InternalError, ExternalError {
  108.       if (((WizardPage)this).getView() != null) {
  109.          ((WizardPage)this).getView().setModel(this);
  110.       }
  111.  
  112.       if (((WizardPage)this).getView() != null && ((WizardPage)this).getWizard() != null) {
  113.          ((WizardPage)this).getWizard().getView().addPageView(String.valueOf(((WizardPage)this).getId()), ((WizardPage)this).getView());
  114.       }
  115.  
  116.    }
  117.  
  118.    public void loadView() {
  119.    }
  120.  
  121.    public boolean isSkip() {
  122.       return this._skip;
  123.    }
  124.  
  125.    public void setSkip(boolean value) {
  126.       this._skip = value;
  127.    }
  128.  
  129.    public boolean isRegisteredWithWizard() {
  130.       return !super.dmId.equals("");
  131.    }
  132.  
  133.    public void validate() throws InternalError, ExternalError {
  134.       this.commitView();
  135.    }
  136.  
  137.    protected void commitView() {
  138.       if (((WizardPage)this).getView() != null) {
  139.          ((WizardViewAbstract)((WizardPage)this).getView()).commit();
  140.       }
  141.  
  142.    }
  143. }
  144.